//
//  TopCell.m
//  Project1
//
//  Created by 黄珂耀 on 15/7/21.
//  Copyright (c) 2015年 黄珂耀. All rights reserved.
//

#import "TopCell.h"
#import "StarView.h"
#import "UIImageView+WebCache.h"

@implementation TopCell

- (void)awakeFromNib {
    // Initialization code
}


- (void)setModal:(TopModal *)modal
{
    _modal = modal;
    [self setNeedsLayout];
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    self.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"bg_main"]];
    
    _titleLabel.text = _modal.title;
    [_titleLabel setTextAlignment:NSTextAlignmentCenter];
    _titleLabel.textColor = [UIColor whiteColor];
    
    [self setStar];
    
    _averageLabel.text = [NSString stringWithFormat:@"%.1f",_modal.average];
    _averageLabel.textColor = [UIColor orangeColor];
    
    NSString *imageURl = [_modal.images objectForKey:@"large"];
    [_topImageView sd_setImageWithURL:[NSURL URLWithString:imageURl]];
    
}

- (void)setStar
{
    StarView *starView = [[StarView alloc] initWithFrame:CGRectMake(10., 145, 90, 16)];
    starView.average = _modal.average;
    [self addSubview:starView];
    
}



@end
